# http://www.gnu.org/software/make/manual/make.html

SHELL = /bin/sh

TARGET_NAME = C4

#### Start of system configuration section. ####
 
srcdir = .
CC = g++

DEFS = 
#-DOUTPUT_DEBUG_INFO
LIBS =

CDEBUG = -o -v -p
# -g debug symbols
# add -c to CDEBUG to skip linking

# Platform independent
CXXFLAGS = $(CDEBUG) -I. -I$(srcdir) -I/opt/local/include $(DEFS) -fmessage-length=0 -pipe -trigraphs -O3 -funroll-loops -ftree-vectorize -mmmx -msse -msse2 -msse3 -mssse3 -fvisibility=hidden -fvisibility-inlines-hidden -msse4.1 -msse4.2 -mfpmath=sse -ffast-math -ffast-math -fno-threadsafe-statics -fno-rtti -fomit-frame-pointer

# generate profiling code: -pg

# Position dependent code: -mdynamic-no-pic
# Reuse string literals:  -fwritable-strings
# Relax IEEE compliance for floats: -ffast-math
# Statics are not thread safe: -fno-threadsafe-statics
# No virtual function table: -fno-rtti
# Static link: -static
# Built in functions not recognized, debugging problems arise: -fno-builtin

# -floop-strip-mine
# -floop-block



#Fjarlægið -fomit-frame-pointer áður en þið reynið að debug'a

OS = $(shell uname)
ifeq ($(OS), Linux)
	CXXFLAGS += -march=native 
#-static problematic -> pthreads
else ifeq ($(OS), Darwin)
	CXXFLAGS += -mmacosx-version-min=10.6 -arch x86_64 -mdynamic-no-pic  -fpascal-strings -fasm-blocks
endif

LDFLAGS = -ldl -lpthread -static-libgcc -dead_strip
#-lstdc++-static 
# add -pg to linking for profiling

VPATH = 

 #### End of system configuration section. ####

# --------------------------------------------------------   MAIN   --------------------------------------------------------

MAIN = main.o

OBJS = $(MAIN) Common.o Utility.o UtilityV2.o bitboard.o MiniMaxSearch.o AlphaBetaSearch.o IterativeDeepeningAlphaBetaSearch.o IterativeDeepeningAlphaBetaSearchKillerMoves.o

.PHONY: all
all: $(TARGET_NAME)

.PHONY: $(TARGET_NAME)
$(TARGET_NAME) : $(OBJS) 
		$(CC) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

.PHONY: clean
clean: 
	rm -f *.o $(TARGET_NAME)



